<template>
   <div>
    <input class='input' placeholder='用户名' v-model='username'/>

   </div>
   <div>
       <input type="password"  placeholder='请输入密码'
        v-model='password'
        />
   </div>
   <button @click='dianBtn'>点击登录</button>
   <MyToast v-if='show' :toastMessage='toastMessage'/>
</template>
<script>
 import MyToast,{useToastEffect} from '@/components/MyToast.vue'
 const useLoginEffect=(showToast)=>{
     const data=reactive({
         username:"",
         password:""
     })
     const router=useRouter();
     const handleLogin=async ()=>{
         try{
            const result=await EetchLogin({
                username:data.username,
                password:data.password
            });
            if(result.code===0){
                router.push({name:"Home"});

            }
            else
            {
                showToast("登录失败")
            }
         }catch(e){
             showToast("请求失败")
         }
     }
     return{
         ...toRefs(data)
         handleLogin,
     }
 }
export default {
    
}
</script>